﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Caching;
using System.Data;
using DBAccess;
using System.Linq;
using LOG;
using DaoDataEntity;
using MySql.Data.MySqlClient;

namespace CacheAccess
{
    
   public class CacheManager
    {
       private static DataSet SBDDS = null;
       private ObjectCache cache = null;
       public static MutilDictionary<int,List<BackageEntity>> m_Backage;
       public static MutilDictionary<int, BaseinfoEntity> m_Baseinfo;
       public static MutilDictionary<int, ConsumeinfoEntity> m_Consumeinfo;
       public static MutilDictionary<int, List<EnemyinfoEntity>> m_Enemyinfo;
       public static MutilDictionary<int, EquipbaseinfoEntity> m_Equipbaseinfo;
       public static MutilDictionary<int, EquipinfoEntity> m_Equipinfo;
       public static MutilDictionary<int, GlobleinfoEntity> m_Globleinfo;
       public static MutilDictionary<int, MapInfoEntity> m_MapInfo;
       public static MutilDictionary<int, MasterinfoEntity> m_Masterinfo;
       public static MutilDictionary<int, MonsterinfoEntity> m_Monsterinfo;
       public static MutilDictionary<int, PaperinfoEntity> m_Paperinfo;
       public static MutilDictionary<int, ProbilainfoEntity> m_Probilainfo;
       public static MutilDictionary<int, SkillInfoEntity> m_SkillInfo;
       public static MutilDictionary<int, StuffinfoEntity> m_Stuffinfo;
       public static MutilDictionary<int, TaskinfoEntity> m_Taskinfo;
       public static MutilDictionary<int, WarriorinfoEntity> m_Warriorinfo;


       public CacheManager()
       {
           if (SBDDS == null||cache==null)
           {
               cache = MemoryCache.Default;
               CacheItemPolicy policy = new CacheItemPolicy();
               policy.SlidingExpiration = new TimeSpan(1, 0, 0, 0);
               SBDDS = new DataSet();
               Common com = new Common();
               DataTable tmp = new DataTable();
               MySqlCommand cmd = new MySqlCommand();
               cmd.CommandText = "select * from";
               tmp = com.getDataTable(cmd);
               string tempcmd = "select * form {0} order by {1} {2}";
               for (int i = 0; i < tmp.Rows.Count; i++)
               {

                   switch (tmp.Rows[i][0].ToString())
                   {
                       case "backage":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "MasterID","ASC");
                           break;
                       case "baseinfo":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "BaseInfoID", "ASC");
                           break;
                       case "consumeinfo":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "ConsumeInfoID", "ASC");
                           break;
                       case "enemyinfo":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "SelfID", "ASC");
                           break;
                       case "equipbaseinfo":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "EquipBaseInfoID", "ASC");
                           break;
                       case "equipinfo":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "EquipInfoID", "ASC");
                           break;
                       case "globleinfo":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "GlobleID", "ASC");
                           break;
                       case "masterinfo":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "MasterInfoID", "ASC");
                           break;
                       case "monsterinfo":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "MonsterInfoID", "ASC");
                           break;
                       case "paperinfo":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "PaperInfoID", "ASC");
                           break;
                       case "probilainfo":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "ProbilaID", "ASC");
                           break;
                       case "skillinfo":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "SkillInfoID", "ASC");
                           break;
                       case "stuffinfo":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "StuffInfoID", "ASC");
                           break;
                       case "taskinfo":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "TaskInfoID", "ASC");
                           break;
                       case "warriorinfo":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "WarriorInfoID", "ASC");
                           break;
                       case "mapinfo":
                           tempcmd = string.Format(tempcmd, tmp.Rows[i][0].ToString(), "MapInfoID", "ASC");
                           break;
                       default:
                           Log.Add("该表未转换成相应的字段类" + tmp.Rows[i][0].ToString(), -899);
                           break;
                   }
                   cmd.CommandText = tempcmd;
                   SBDDS.Tables.Add(com.getDataTable(cmd).TableName = tmp.Rows[i][0].ToString());
                   DataTableToDictionary();
               }
           }
       }
    

       private void DataTableToDictionary()
       {
           if (SBDDS == null) Log.Add("SBDDS为空,可能数据库连接错误.", -898);
           for (int i = 0; i < SBDDS.Tables.Count; i++)
           {
               switch (SBDDS.Tables[i].TableName)
               {
                   case "backage":
                       List<BackageEntity> beList = new List<BackageEntity>();
                       BackageEntity be = new BackageEntity();
                       m_Backage = new MutilDictionary<int,List< BackageEntity>>();
                       for (int j = 0; j < SBDDS.Tables[i].Rows.Count; j++)
                       {
                           be.BackageID = int.Parse(SBDDS.Tables[i].Rows[j]["BackageID"].ToString());
                           be.GoodsID = int.Parse(SBDDS.Tables[i].Rows[j]["GoodsID"].ToString());
                           be.GoodsType = SBDDS.Tables[i].Rows[j]["GoodsType"].ToString();
                           be.MasterID = int.Parse(SBDDS.Tables[i].Rows[j]["MasterID"].ToString());
                           be.PlatformSign = SBDDS.Tables[i].Rows[j]["PlatformSign"].ToString();
                           if (m_Backage.ContainsKey(be.MasterID))
                           {
                               beList = m_Backage[be.MasterID];
                               beList.Add(be);
                               m_Backage[be.MasterID] = beList;
                           }
                           else
                           {
                               beList.Clear();
                               beList.Add(be);
                               m_Backage.Add(be.MasterID, beList);
                           }
                          
                       }
                           break;
                   case "baseinfo":
                           BaseinfoEntity baseinfo = new BaseinfoEntity();
                           m_Baseinfo = new MutilDictionary<int, BaseinfoEntity>();
                           for (int k = 0; k < SBDDS.Tables[i].Rows.Count; k++)
                           {
                               baseinfo._BaseInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["BaseInfoID"].ToString());
                               baseinfo._Exper = int.Parse(SBDDS.Tables[i].Rows[k]["Exper"].ToString());
                               baseinfo._LastLoginTime = Convert.ToDateTime(SBDDS.Tables[i].Rows[k]["LastLoginTime"].ToString());
                               baseinfo._Level = int.Parse(SBDDS.Tables[i].Rows[k]["Levels"].ToString());
                               baseinfo._Life = int.Parse(SBDDS.Tables[i].Rows[k]["Life"].ToString());
                               baseinfo._LoginTimes = int.Parse(SBDDS.Tables[i].Rows[k]["LoginTimes"].ToString());
                               baseinfo._Magic = int.Parse(SBDDS.Tables[i].Rows[k]["Magic"].ToString());
                               baseinfo._PlatformSign = SBDDS.Tables[i].Rows[k]["PlatformSign"].ToString();
                               baseinfo._Power = int.Parse(SBDDS.Tables[i].Rows[k]["Power"].ToString());
                               baseinfo._Profession = SBDDS.Tables[i].Rows[k]["Profession"].ToString();
                               baseinfo._Quick = int.Parse(SBDDS.Tables[i].Rows[k]["Quick"].ToString());
                               baseinfo._RegisterTime = Convert.ToDateTime(SBDDS.Tables[i].Rows[k]["RegisterTime"].ToString());
                               baseinfo._Strong = int.Parse(SBDDS.Tables[i].Rows[k]["Strong"].ToString());
                               baseinfo._Wakan = int.Parse(SBDDS.Tables[i].Rows[k]["Wakan"].ToString());
                               if (m_Baseinfo.ContainsKey(baseinfo._BaseInfoID))
                                    m_Baseinfo.Remove(baseinfo._BaseInfoID);
                               m_Baseinfo.Add(baseinfo._BaseInfoID, baseinfo);
                           }
                               break;
                   case "consumeinfo":
                               ConsumeinfoEntity consume = new ConsumeinfoEntity();
                               m_Consumeinfo = new MutilDictionary<int, ConsumeinfoEntity>();
                               for (int k = 0; k < SBDDS.Tables[i].Rows.Count; k++)
                               {
                                   consume.ConsumeDes = SBDDS.Tables[i].Rows[k]["ConsumeDes"].ToString();
                                   consume.ConsumeInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["ConsumeInfoID"].ToString());
                                   consume.ConsumeName = SBDDS.Tables[i].Rows[k]["ConsumeName"].ToString();
                                   consume.Excep = SBDDS.Tables[i].Rows[k]["Excep"].ToString();
                                   consume.Price = int.Parse(SBDDS.Tables[i].Rows[k]["Price"].ToString());
                                   if (m_Consumeinfo.ContainsKey(consume.ConsumeInfoID))
                                       m_Consumeinfo.Remove(consume.ConsumeInfoID);
                                   m_Consumeinfo.Add(consume.ConsumeInfoID, consume);
                               }
                       break;
                   case "enemyinfo":
                       EnemyinfoEntity enemy = new EnemyinfoEntity();
                       List<EnemyinfoEntity> enemyList=new List<EnemyinfoEntity>();
                       m_Enemyinfo = new MutilDictionary<int,List<EnemyinfoEntity>>();
                       for (int k = 0; k < SBDDS.Tables[i].Rows.Count; k++)
                       {
                           enemy.EnemyID = int.Parse(SBDDS.Tables[i].Rows[k]["EnemyID"].ToString());
                           enemy.EnemyInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["EnemyInfoID"].ToString());
                           enemy.EnemyValues = int.Parse(SBDDS.Tables[i].Rows[k]["EnemyValues"].ToString());
                           enemy.SelfID = int.Parse(SBDDS.Tables[i].Rows[k]["SelfID"].ToString());
                           enemy.Time = Convert.ToDateTime(SBDDS.Tables[i].Rows[k]["Time"].ToString());

                           if (m_Enemyinfo.ContainsKey(enemy.SelfID))
                           {
                               enemyList = m_Enemyinfo[enemy.SelfID];
                               enemyList.Add(enemy);
                               m_Enemyinfo[enemy.SelfID] = enemyList;
                           }
                           else
                           {
                               enemyList.Clear();
                               enemyList.Add(enemy);
                               m_Enemyinfo.Add(enemy.SelfID, enemyList);
                           }
                       }
                       break;
                   case "equipbaseinfo":
                       EquipbaseinfoEntity equipbase = new EquipbaseinfoEntity();
                       m_Equipbaseinfo = new MutilDictionary<int, EquipbaseinfoEntity>();
                       for (int k = 0; k < SBDDS.Tables[i].Rows.Count; k++)
                       {
                           equipbase.EquipBaseInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["EquipBaseInfoID"].ToString());
                           equipbase.EquipName = SBDDS.Tables[i].Rows[k]["EquipName"].ToString();
                           equipbase.EquipType = SBDDS.Tables[i].Rows[k]["EquipType"].ToString();
                           equipbase.IsSuit =Convert.ToBoolean(SBDDS.Tables[i].Rows[k]["IsSuit"]);
                           equipbase.Limit = SBDDS.Tables[i].Rows[k]["Limit"].ToString();
                           equipbase.NormalAttrbiExcep = SBDDS.Tables[i].Rows[k]["NormalAttrbiExcep"].ToString();
                           equipbase.Price = int.Parse(SBDDS.Tables[i].Rows[k]["Price"].ToString());
                           equipbase.SuitAttrbiExcep = SBDDS.Tables[i].Rows[k]["SuitAttrbiExcep"].ToString();
                           equipbase.SuitSign = int.Parse(SBDDS.Tables[i].Rows[k]["SuitSign"].ToString());
                           if (m_Equipbaseinfo.ContainsKey(equipbase.EquipBaseInfoID))
                               m_Equipbaseinfo.Remove(equipbase.EquipBaseInfoID);
                           m_Equipbaseinfo.Add(equipbase.EquipBaseInfoID, equipbase);
                       }
                       break;
                   case "equipinfo":
                       EquipinfoEntity equip = new EquipinfoEntity();
                       m_Equipinfo = new MutilDictionary<int, EquipinfoEntity>();
                       for (int k = 0; k < SBDDS.Tables[i].Rows.Count; k++)
                       {
                           equip.AddGem = SBDDS.Tables[i].Rows[k]["AddGem"].ToString();
                           equip.EquipBaseInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["EquipBaseInfoID"].ToString());
                           equip.EquipInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["EquipInfoID"].ToString());
                           equip.HoleNum = int.Parse(SBDDS.Tables[i].Rows[k]["HoleNum"].ToString());
                           equip.MakerID = int.Parse(SBDDS.Tables[i].Rows[k]["MakerID"].ToString());
                           equip.StrongLevel = int.Parse(SBDDS.Tables[i].Rows[k]["StrongLevel"].ToString());
                           if(m_Equipinfo.ContainsKey(equip.EquipInfoID))
                               m_Equipinfo.Remove(equip.EquipInfoID);
                           m_Equipinfo.Add(equip.EquipInfoID,equip);
                       }
                       break;
                   case "globleinfo":
                       GlobleinfoEntity globle = new GlobleinfoEntity();
                       m_Globleinfo = new MutilDictionary<int, GlobleinfoEntity>();
                       for (int k = 0; k < SBDDS.Tables[i].Rows.Count; k++)
                       {
                           globle.GlobleDes= SBDDS.Tables[i].Rows[k]["GlobleDes"].ToString();
                           globle.GlobleID = int.Parse(SBDDS.Tables[i].Rows[k]["GlobleID"].ToString());
                           globle.GlobleSign = SBDDS.Tables[i].Rows[k]["GlobleSign"].ToString();
                           globle.GlobleSubType = SBDDS.Tables[i].Rows[k]["GlobleSubType"].ToString();
                           globle.GlobleValue = SBDDS.Tables[i].Rows[k]["GlobleValue"].ToString();
                           if (m_Globleinfo.ContainsKey(globle.GlobleID))
                               m_Globleinfo.Remove(globle.GlobleID);
                           m_Globleinfo.Add(globle.GlobleID, globle);
                       }
                       break;
                   case "masterinfo":
                       MasterinfoEntity master = new MasterinfoEntity();
                       m_Masterinfo = new MutilDictionary<int, MasterinfoEntity>();
                       for (int k = 0; k < SBDDS.Tables[i].Rows.Count; k++)
                       {
                           master.AddSkillNum = int.Parse(SBDDS.Tables[i].Rows[k]["AddSkillNum"].ToString());
                           master.Army = int.Parse(SBDDS.Tables[i].Rows[k]["Army"].ToString());
                           master.BaseInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["BaseInfoID"].ToString());
                           master.Belt = int.Parse(SBDDS.Tables[i].Rows[k]["Belt"].ToString());
                           master.Clouth = int.Parse(SBDDS.Tables[i].Rows[k]["Clouth"].ToString());
                           master.Gold = int.Parse(SBDDS.Tables[i].Rows[k]["Gold"].ToString());
                           master.Headpiece = int.Parse(SBDDS.Tables[i].Rows[k]["Headpiece"].ToString());
                           master.IsNew = Convert.ToBoolean(SBDDS.Tables[i].Rows[k]["IsNew"]);
                           master.Jewelry = int.Parse(SBDDS.Tables[i].Rows[k]["Jewelry"].ToString());
                           master.LoginKey = SBDDS.Tables[i].Rows[k]["LoginKey"].ToString();
                           master.MasterInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["MasterInfoID"].ToString());
                           master.PlatformSign = SBDDS.Tables[i].Rows[k]["PlatformSign"].ToString();
                           master.RMB = int.Parse(SBDDS.Tables[i].Rows[k]["RMB"].ToString());
                           master.Shoes = int.Parse(SBDDS.Tables[i].Rows[k]["Shoes"].ToString());
                           master.Skill = SBDDS.Tables[i].Rows[k]["Skill"].ToString();
                           master.SkillNum = int.Parse(SBDDS.Tables[i].Rows[k]["SkillNum"].ToString());
                           master.Task = SBDDS.Tables[i].Rows[k]["Task"].ToString();
                           master.Warrior = SBDDS.Tables[i].Rows[k]["Warrior"].ToString();
                           master.Baseinfo = m_Baseinfo[master.BaseInfoID];
                           if (master.Baseinfo == null)
                               Log.Add("master表中有baseinfo中不存在的字段:"+master.BaseInfoID.ToString(), -893);
                           if (m_Masterinfo.ContainsKey(master.MasterInfoID))
                               m_Masterinfo.Remove(master.MasterInfoID);
                           m_Masterinfo.Add(master.MasterInfoID, master);
                       }
                       break;
                   case "monsterinfo":
                       MonsterinfoEntity monster = new MonsterinfoEntity();
                       m_Monsterinfo = new MutilDictionary<int, MonsterinfoEntity>();
                       for (int k = 0; k < SBDDS.Tables[i].Rows.Count; k++)
                       {
                           monster.Image = SBDDS.Tables[i].Rows[k]["Image"].ToString();
                           monster.LostExcep = SBDDS.Tables[i].Rows[k]["LostExcep"].ToString();
                           monster.MonsterDes =SBDDS.Tables[i].Rows[k]["MonsterDes"].ToString();
                           monster.MonsterInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["MonsterInfoID"].ToString());
                           monster.MonsterLevel = int.Parse(SBDDS.Tables[i].Rows[k]["MonsterLevel"].ToString());
                           monster.MonsterName = SBDDS.Tables[i].Rows[k]["MonsterName"].ToString();
                           monster.MonsterPlace = SBDDS.Tables[i].Rows[k]["MonsterPlace"].ToString();
                           monster.Power = int.Parse(SBDDS.Tables[i].Rows[k]["Power"].ToString());
                           monster.Quick = int.Parse(SBDDS.Tables[i].Rows[k]["Quick"].ToString());

                           monster.Skill = SBDDS.Tables[i].Rows[k]["Skill"].ToString();
                           monster.Strong = int.Parse(SBDDS.Tables[i].Rows[k]["Strong"].ToString());
                           monster.Wakan = int.Parse(SBDDS.Tables[i].Rows[k]["Wakan"].ToString());
                           if (m_Monsterinfo.ContainsKey(monster.MonsterInfoID))
                               m_Monsterinfo.Remove(monster.MonsterInfoID);
                           m_Monsterinfo.Add(monster.MonsterInfoID,monster);
                       }
                       break;
                   case "paperinfo":
                       PaperinfoEntity paper = new PaperinfoEntity();
                       m_Paperinfo = new MutilDictionary<int, PaperinfoEntity>();
                       for (int k = 0; k < SBDDS.Tables[i].Rows.Count; k++)
                       {
                           paper.Exper = SBDDS.Tables[i].Rows[k]["Exper"].ToString();
                           paper.PaperDes = SBDDS.Tables[i].Rows[k]["PaperDes"].ToString();
                           paper.PaperInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["PaperInfoID"].ToString());
                           paper.PaperName = SBDDS.Tables[i].Rows[k]["PaperName"].ToString();
                           paper.Price = int.Parse(SBDDS.Tables[i].Rows[k]["Price"].ToString());
                           paper.RequestExper = SBDDS.Tables[i].Rows[k]["RequestExper"].ToString();
                           if (m_Paperinfo.ContainsKey(paper.PaperInfoID))
                               m_Paperinfo.Remove(paper.PaperInfoID);
                           m_Paperinfo.Add(paper.PaperInfoID, paper);
                       }
                       break;
                   case "probilainfo":
                       ProbilainfoEntity probila = new ProbilainfoEntity();
                       m_Probilainfo = new MutilDictionary<int, ProbilainfoEntity>();
                       for (int k = 0; k < SBDDS.Tables[i].Rows.Count; k++)
                       {
                           probila.GoodsID= int.Parse(SBDDS.Tables[i].Rows[k]["GoodsID"].ToString());
                           probila.GoodsType = SBDDS.Tables[i].Rows[k]["GoodsType"].ToString();
                           probila.GrobilaExcep = SBDDS.Tables[i].Rows[k]["GrobilaExcep"].ToString();
                           probila.ProbilaDes = SBDDS.Tables[i].Rows[k]["ProbilaDes"].ToString();
                           probila.ProbilaID = int.Parse(SBDDS.Tables[i].Rows[k]["ProbilaID"].ToString());
                           probila.ProbilaName = SBDDS.Tables[i].Rows[k]["ProbilaName"].ToString();
                           if (m_Probilainfo.ContainsKey(probila.ProbilaID))
                               m_Probilainfo.Remove(probila.ProbilaID);
                           m_Probilainfo.Add(probila.ProbilaID, probila);

                       }
                       break;
                   case "skillinfo":
                       SkillInfoEntity skill = new SkillInfoEntity();
                       m_SkillInfo = new MutilDictionary<int, SkillInfoEntity>();
                       for (int k = 0; k < SBDDS.Tables[i].Rows.Count; k++)
                       {
                           skill.LimitExcep = SBDDS.Tables[i].Rows[k]["LimitExcep"].ToString();
                           skill.SkillDes = SBDDS.Tables[i].Rows[k]["SkillDes"].ToString();
                           skill.SkillExcep = SBDDS.Tables[i].Rows[k]["SkillExcep"].ToString();
                           skill.SkillInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["SkillInfoID"].ToString());
                           skill.SkillLevel =int.Parse( SBDDS.Tables[i].Rows[k]["SkillLevel"].ToString());
                           skill.SkillName = SBDDS.Tables[i].Rows[k]["SkillName"].ToString();
                           skill.SkillType = int.Parse(SBDDS.Tables[i].Rows[k]["SkillType"].ToString());
                           if (m_SkillInfo.ContainsKey(skill.SkillInfoID))
                               m_SkillInfo.Remove(skill.SkillInfoID);
                           m_SkillInfo.Add(skill.SkillInfoID, skill);
                       }
                       break;
                   case "stuffinfo":
                       StuffinfoEntity stuff = new StuffinfoEntity();
                       m_Stuffinfo = new MutilDictionary<int, StuffinfoEntity>();
                       for (int k = 0; k < SBDDS.Tables[i].Rows.Count; k++)
                       {
                           stuff.Price = int.Parse(SBDDS.Tables[i].Rows[k]["Price"].ToString());
                           stuff.StuffDes = SBDDS.Tables[i].Rows[k]["StuffDes"].ToString();
                           stuff.StuffInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["StuffInfoID"].ToString());
                           stuff.StuffName = SBDDS.Tables[i].Rows[k]["StuffName"].ToString();
                           if (m_Stuffinfo.ContainsKey(stuff.StuffInfoID))
                               m_Stuffinfo.Remove(stuff.StuffInfoID);
                           m_Stuffinfo.Add(stuff.StuffInfoID, stuff);
                       }
                       break;
                   case "taskinfo":
                       TaskinfoEntity task = new TaskinfoEntity();
                       m_Taskinfo = new MutilDictionary<int, TaskinfoEntity>();
                       for (int k = 0; k < SBDDS.Tables[i].Rows.Count; k++)
                       {
                           task.LimitExcep = SBDDS.Tables[i].Rows[k]["LimitExcep"].ToString();
                           task.NextTask = int.Parse(SBDDS.Tables[i].Rows[k]["NextTask"].ToString());
                           task.RewordExcep = SBDDS.Tables[i].Rows[k]["RewordExcep"].ToString();
                           task.TaskDes = SBDDS.Tables[i].Rows[k]["TaskDes"].ToString();
                           task.TaskInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["TaskInfoID"].ToString());
                           task.TaskName = SBDDS.Tables[i].Rows[k]["TaskName"].ToString();
                           task.TaskPlace = SBDDS.Tables[i].Rows[k]["TaskPlace"].ToString();
                           task.TaskType = int.Parse(SBDDS.Tables[i].Rows[k]["TaskType"].ToString());
                           if (m_Taskinfo.ContainsKey(task.TaskInfoID))
                               m_Taskinfo.Remove(task.TaskInfoID);
                           m_Taskinfo.Add(task.TaskInfoID, task);
                       }
                       break;
                   case "warriorinfo":
                       WarriorinfoEntity warr = new WarriorinfoEntity();
                       m_Warriorinfo = new MutilDictionary<int, WarriorinfoEntity>();
                       for (int k = 0; k < SBDDS.Tables[i].Rows.Count; k++)
                       {
                           warr.AddSkillNum = int.Parse(SBDDS.Tables[i].Rows[k]["AddSkillNum"].ToString());
                           warr.Army = int.Parse(SBDDS.Tables[i].Rows[k]["Army"].ToString());
                           warr.BaseInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["BaseInfoID"].ToString());
                           warr.Belt = int.Parse(SBDDS.Tables[i].Rows[k]["Belt"].ToString());
                           warr.Clouth = int.Parse(SBDDS.Tables[i].Rows[k]["Clouth"].ToString());
                           warr.Headpiece = int.Parse(SBDDS.Tables[i].Rows[k]["Headpiece"].ToString());
                           warr.Jewelry = int.Parse(SBDDS.Tables[i].Rows[k]["Jewelry"].ToString());
                           warr.Loyalty = int.Parse(SBDDS.Tables[i].Rows[k]["Loyalty"].ToString());
                           warr.PlatformSign = SBDDS.Tables[i].Rows[k]["PlatformSign"].ToString();
                           warr.Satiety = int.Parse(SBDDS.Tables[i].Rows[k]["Satiety"].ToString());
                           warr.Shoes = int.Parse(SBDDS.Tables[i].Rows[k]["Shoes"].ToString());
                           warr.Skill = SBDDS.Tables[i].Rows[k]["Skill"].ToString();
                           warr.SkillNum = int.Parse(SBDDS.Tables[i].Rows[k]["SkillNum"].ToString());
                           warr.WarriorInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["WarriorInfoID"].ToString());
                           if(m_Warriorinfo.ContainsKey(warr.WarriorInfoID))
                               m_Warriorinfo.Remove(warr.WarriorInfoID);
                           m_Warriorinfo.Add(warr.WarriorInfoID, warr);
                       }
                       break;
                   case "mapinfo":
                       MapInfoEntity map = new MapInfoEntity();
                       m_MapInfo = new MutilDictionary<int, MapInfoEntity>();
                       for (int k = 0; k < SBDDS.Tables[i].Rows.Count; k++)
                       {
                           map.MapInfoID = int.Parse(SBDDS.Tables[i].Rows[k]["MapInfoID"].ToString());
                           map.MonsterList = SBDDS.Tables[i].Rows[k]["MonsterList"].ToString();
                           map.TaskList = SBDDS.Tables[i].Rows[k]["TaskList"].ToString();
                           if (m_MapInfo.ContainsKey(map.MapInfoID))
                               m_MapInfo.Remove(map.MapInfoID);
                           m_MapInfo.Add(map.MapInfoID, map);
                       }
                       break;
                   default:
                       break;
               }
              
           }

       }

   
    }
}
